package org.example.studentsystem_back.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.studentsystem_back.common.CommonResponse;
import org.example.studentsystem_back.domain.Counselor;
import org.example.studentsystem_back.dto.PageDTO;
import org.example.studentsystem_back.service.CounselorService;
import org.example.studentsystem_back.vo.counselorMangeVo.CounselorVo;
import org.example.studentsystem_back.vo.userManageVo.PageCounselorVo;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@Valid
public class CounselorController {
    @Resource
    private CounselorService counselorService;

    //获取所有辅导员
    @GetMapping("/counselors")
    public CommonResponse<List<Counselor>> getAllCounselor(){
        return counselorService.getAllCounselor();
    }

    //根据userId查询辅导员
    @GetMapping("/counselors/{userId}")
    public CommonResponse<CounselorVo> getCounselorByUserId(@PathVariable("userId") String userId){
        return counselorService.getCounselorByUserId(userId);
    }

    //根据userId修改辅导员信息
    @PutMapping("/counselors/{userId}")
    public CommonResponse<CounselorVo> updateCounselor(@PathVariable("userId") String userId,@RequestBody Counselor counselor){
        return counselorService.getCounselorByUserId(userId);
    }

    //获取当前辅导员信息
    @GetMapping("/counselors/current")
    public CommonResponse<CounselorVo> getCurrentCounselor(HttpServletRequest httpServletRequest){
        return counselorService.getCurrentCounselor(httpServletRequest);
    }
    //删除辅导员
    //添加辅导员

    //分页查询辅导员
    @PostMapping("/counselors/page")
    public CommonResponse<PageCounselorVo> getAllCounselorByPage(@RequestBody PageDTO pageDTO){
        return counselorService.getAllCounselorByPage(pageDTO);
    }
}
